/*
 * Display.h
 *
 *  Created on: Dec 11, 2011
 *      Author: Michael Anderson
 *      Part of Team 955 Battery Cart project
 *      compiled on Eclipse with Arduino libraries and avr-gcc
 */

#ifndef DISPLAY_H_
#define DISPLAY_H_

#include <Arduino.h>
#include <HardwareSerial.h>
#include <LiquidCrystal.h>
#include "enums.h"
#include "Timer.h"

class Display {
public:
    Display(uint8_t ID, uint8_t rs, uint8_t rw, uint8_t enable, uint8_t d0, uint8_t d1, uint8_t d2, uint8_t d3, uint8_t d4, uint8_t d5, uint8_t d6, uint8_t d7);
    void run();
    void setLine(uint8_t, char*, bool = false, bool = false);
    void setChar(uint8_t, uint8_t, char);
    uint16_t getStrLength(char*);
    uint8_t getID();
    bool fullScreenIsActive();
    void setFullScreen(bool);
    void clear(bool);
    void lock();
    void unlock();

private:
    bool locked;
    uint8_t displayID;
    LiquidCrystal *lcd;
    bool tickerStates[DISPLAY_ROWS];
    uint16_t tickerPos[DISPLAY_ROWS];
    uint16_t tickerLens[DISPLAY_ROWS];
    char lines[DISPLAY_ROWS][MAX_TICKER_LEN];
    bool fullScreenActive;
    uint32_t tickerClock;

    void scrollTicker(uint8_t);
};

#endif /* DISPLAY_H_ */
